var app = getApp();

Page({
    data: {
        luntext: [ "全部", "待参加", "审核中", "已验票", "退票" ],
        activeIndex: 0,
        page: 1,
        my_tickets: []
    },
    onLoad: function(t) {
        wx.hideShareMenu();
        this.setData({
            activity_id: t.activity_id
        }), this.refresh();
    },
    refresh: function(t) {
        var a, i = this, n = i.data.page, e = i.data.activeIndex, d = i.data.activity_id;
        0 == e ? a = "" : 1 == e ? a = "2" : 2 == e ? a = "1" : 3 == e ? a = "3" : 4 == e && (a = "5"), 
        console.log(a);
        var s = i.data.my_tickets;
        app.util.request({
            url: "entry/wxapp/HdPjlist",
            cachetime: "0",
            data: {
                activity_id: d,
                state: a,
                page: n
            },
            success: function(t) {
                if (console.log(t), 0 < t.data.length) {
                    i.setData({
                        page: n + 1,
                        many: !0
                    }), s = s.concat(t.data);
                    var a = app.today_time();
                    for (var e in console.log(a), t.data) t.data[e].end_time = app.ormatDate(t.data[e].end_time), 
                    a > t.data[e].end_time ? (t.data[e].state = "失效", t.data[e].states = 2) : a <= t.data[e].end_time && (4 == t.data[e].state ? (t.data[e].state = "已申请退票", 
                    t.data[e].states = 2) : 5 == t.data[e].state ? (t.data[e].state = "已退票", t.data[e].states = 2) : (t.data[e].state = "有效", 
                    t.data[e].states = 1)), t.data[e].end = t.data[e].end_time.slice(0, 16), 1 == t.data[e].hd_place ? t.data[e].hd_place = "线上活动" : t.data[e].hd_place = "线下活动";
                    i.setData({
                        my_tickets: s
                    });
                } else i.setData({
                    page: n,
                    many: !1
                });
            }
        });
    },
    piaoinfo: function(t) {
        var a = t.currentTarget.dataset.index, e = this.data.my_tickets[a];
        wx.navigateTo({
            url: "../mycenter/check_info?id=" + e.id + "&hd_title=" + e.hd_title + "&img=" + e.img + "&name=" + e.tk_name + "&tk_name= &time=" + e.time
        });
    },
    tabClick: function(t) {
        this.setData({
            activeIndex: t.currentTarget.id,
            page: 1,
            my_tickets: []
        }), this.refresh();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.setData({
            page: 1,
            my_tickets: []
        }), this.refresh(), wx.stopPullDownRefresh();
    },
    onReachBottom: function() {
        console.log("上拉触底"), this.refresh();
    }
});